package pers.whj.util.list;

public interface List<T> extends Iterable<T> {
    int length();

    boolean contains(Object data);

    int find(Object data);

    /**
     * find specified data from back to front
     *
     * @param data target data
     * @return the target index or -1
     */
    int findFromLast(Object data);

    /**
     * find data in specified range
     *
     * @param data  target data
     * @param start from index (inclusive)
     * @param end   stop index (inclusive)
     * @return the target index or -1
     */
    int find(Object data, int start, int end);

    /**
     * the num of specified data
     *
     * @param data specified data
     * @return the amounts
     */
    int count(Object data);

    T get(int index);

    T getHead();

    T getTail();

    T set(int index, T data);

    T setHead(T data);

    T setTail(T data);

    void setAll(T data);

    boolean insert(T data);

    boolean insert(int index, T data);

    boolean insert(int index, T[] data);

    boolean insertHead(T data);

    boolean insertTail(T data);

    T delete();

    T delete(int index);

    void delete(int from, int end);

    boolean delete(Object data);

    /**
     * delete the first specified data from last
     *
     * @param data specified data
     * @return if data exists and successfully delete it
     */
    boolean deleteFromLast(Object data);

    /**
     * delete all specified data
     *
     * @param data specified data
     * @return the num of data to delete
     */
    int deleteAll(Object data);

    T deleteHead();

    T deleteTail();

    boolean isEmpty();

    void clear();

    Iterator<T> iterator();

    Object[] toArray();

    T[] toArray(Class<T> type);
}